﻿@using KRM.Core
@model ExpandoModel
@{
    ViewBag.Title = "Expandos";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var db = new KRMEntities();
}
<div class="container-fluid">
    <div class="row-fluid">
        <div class="box">
            <div class="box-title">
                <h3>Expandos</h3>
            </div>
            <div class="box-content">
                @Html.Partial("Partial/_MessageResult")
                @using (Html.BeginForm("Expando", "Permission", FormMethod.Post, new { @class = "form-horizontal" }))
                {
                    <div class="control-group">
                        <label class="control-label" for="Name">Name</label>
                        <div class="controls">
                            @Html.EditorFor(model => model.Name, new { required = "required" })
                            @Html.ValidationMessageFor(model => model.Name)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="Position">Position</label>
                        <div class="controls">
                            <input type="number" name="Postion" value="0"/>
                            @Html.ValidationMessageFor(model => model.Position)
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Create</button>
                    </div>
                }
            </div>
        </div>
    </div>

    <div class="row-fluid">
        <table class="table table-hover table-bordered table-fix">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in db.WebPermissionExpandos.OrderByDescending(a => a.Position))
                {
                    <tr>
                        <td>
                            @item.ID
                        </td>
                        <td><a href="/permission/editexpando/@item.ID">@item.Name</a></td>
                        <td>@item.Position</td>
                        <td><a href="/permission/deleteexpando/@item.ID" onclick="javascript:return confirm('Are you sure?');">Delete</a></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>